Bounded Linear Types in a Resource Semiring

نویسندگان

  • Dan R. Ghica
  • Alex I. Smith
چکیده

Bounded linear types have proved to be useful for automated resource analysis and control in functional programming languages. In this paper we introduce a bounded linear typing discipline on a general notion of resource which can be modeled in a semiring. For this type system we provide both a general type-inference procedure, parameterized by the decision procedure of the semiring equational theory, and a (coherent) categorical semantics. This could be a useful type-theoretic and denotational framework for resource-sensitive compilation, and it represents a generalization of several existing type systems. As a nontrivial instance, motivated by hardware compilation, we present a complex new application to calculating and controlling timing of execution in a (recursion-free) higher-order functional programming language with local store. 1 Resource-aware types and semantics The two important things about a computer program are what it computes and what resources it needs to carry out the computation successfully. Correctness of the input-output behavior of programs has been, of course, the object of much research from various conceptual angles: logical, semantical, type-theoretical and so on. Resource analysis has been conventionally studied for algorithms, such as time and space complexity, and for programs has long been a part of research in compiler optimization. An exciting development was the introduction of semantic [1] and especially type theoretic [14] characterizations of resource consumption in functional programming languages. Unlike algorithmic analyses, type based analysis are formal and can be statically checked for implementations of algorithms in concrete programming languages. Unlike static analysis, a typing mechanism is compositional which means that it supports, at least in principle, separate compilation and even a foreign function interface: it is an analysis based on signatures rather than implementations. Linear logic and typing, because of the fine-grained treatment of resourcesensitive structural rules, constitute an excellent framework for resource analysis, especially in its bounded fragment [13], which can logically characterize polynomial time computation. Bounded Linear Logic (BLL) was subsequently extended to improve its flexibility while retaining poly-time [5] and further extensions to linear dependent typing were used to completely characterize complexity of evaluation of functional programs [4]. Such analyses use time as a motivating example, but can be readily adapted to other consumable resources such as energy or network traffic. What they have in common is a monadic view of resources, tracking their global usage throughout the execution of the term. A complementary view on resource sensitivity is the co-monadic one, as advocated by Melliès and Tabareau [18]. The intuition is that the type system tracks how much resource a term needs in order to execute successfully. This is quite typical when controlling reusable resources which can be allocated and de-allocated at runtime, the typical example of which is memory, especially local (stack-allocated) memory. In fact this resource-sensitive approach is key in giving a better semantic understanding of higher-order state [17]. This view of resources is instrumental in facilitating the compilation of functional-imperative programming languages directly for resource-constrained runtimes, such as electronic circuits [8]. 2 Bounded linear types over a semiring Types are generated by the grammar θ ::= σ | (J ·θ) ( θ, where σ is a fixed collection of base types and J ∈ J , where (J ,+,×,0,1) is a semiring. We will always take · to bind strongest so we will omit the brackets. Let Γ = x1:J1·θ1, . . . , xn:Jn·θn be a list of identifiers xi and types θi, annotated with semiring elements Ji. Let fv(M) be the set of free variables of term M , defined in the usual way. The typing rules are: Identity x : 1·θ ` x : θ Γ `M : θ Weakening Γ, x : J ·θ′ `M : θ Γ, x : J ·θ `M : θ′ Abstraction Γ ` λx.M : J ·θ ( θ′ Γ `M : J ·θ ( θ′ Γ ′ ` N : θ Application Γ, J ·Γ ′ `MN : θ′ Γ, x : J ·θ, y : K·θ `M : θ′ Contraction Γ, x : (J +K)·θ `M [x/y] : θ′ In Weakening we have the side condition x 6∈ fv(M), and in Application we require dom(Γ ) ∩ dom(Γ ′) = ∅. In the Application rule we use the notation J ·(x1 : K1·θ1, . . . , xn : Kn·θn) , x1 : (J ×K1)·θ1, . . . , xn : (J ×Kn)·θn (1) Note. For the sake of simplicity we take operations in the semiring to be resolved syntactically within the type system. So types such as 2·A and (1 + 1)·A are taken to be syntactically equal. In the context of type-checking this is reasonable because semiring actions are always constants that the type-checker can calculate with. If we were to allow resource variables, i.e. some form of resource-based polymorphism (cf. [5]) then a new structural rule would be required to handle type congruences induced by the semiring theory: Γ, x : J ·θ′ `M : θ J =J J ′ Semiring Γ, x : J ′·θ′ `M : θ But in our current system this level of formalization is not worth the complication.

برای دانلود رایگان متن کامل این مقاله و بیش از 32 میلیون مقاله دیگر ابتدا ثبت نام کنید

ثبت نام

اگر عضو سایت هستید لطفا وارد حساب کاربری خود شوید

منابع مشابه

From bounded affine types to automatic timing analysis

Bounded linear types have proved to be useful for automated resource analysis and control in functional programming languages. In this paper we introduce an affine bounded linear typing discipline on a general notion of resource which can be modeled in a semiring. For this type system we provide both a general type-inference procedure, parameterized by the decision procedure of the semiring equ...

متن کامل

ROBUST RESOURCE-CONSTRAINED PROJECT SCHEDULING WITH UNCERTAIN-BUT-BOUNDED ACTIVITY DURATIONS AND CASH FLOWS I. A NEW SAMPLING-BASED HYBRID PRIMARY-SECONDARY CRITERIA APPROACH

This paper, we presents a new primary-secondary-criteria scheduling model for resource-constrained project scheduling problem (RCPSP) with uncertain activity durations (UD) and cash flows (UC). The RCPSP-UD-UC approach producing a “robust” resource-feasible schedule immunized against uncertainties in the activity durations and which is on the sampling-based scenarios may be evaluated from a cos...

متن کامل

Krivine Machine and Taylor Expansion in a Non-uniform Setting

The Krivine machine is an abstract machine implementing the linear head reduction of λ -calculus. Ehrhard and Regnier gave a resource sensitive version returning the annotated form of a λ -term accounting for the resources used by the linear head reduction. These annotations take the form of terms in the resource λ -calculus. We generalize this resource-driven Krivine machine to the case of the...

متن کامل

A brief introduction to quaternion matrices and linear algebra and on bounded groups of quaternion matrices

The division algebra of real quaternions, as the only noncommutative normed division real algebra up to isomorphism of normed algebras, is of great importance. In this note, first we present a brief introduction to quaternion matrices and quaternion linear algebra. This, among other things, will help us present the counterpart of a theorem of Herman Auerbach in the setting of quaternions. More ...

متن کامل

On semiring complexity of Schur polynomials

Semiring complexity is the version of arithmetic circuit complexity that allows only two operations: addition and multiplication. We show that semiring complexity of a Schur polynomial sλ(x1, . . . , xk) labeled by a partition λ = (λ1 ≥ λ2 ≥ · · · ) is bounded by O(log(λ1)) provided the number of variables k is fixed.

متن کامل

ذخیره در منابع من


  با ذخیره ی این منبع در منابع من، دسترسی به آن را برای استفاده های بعدی آسان تر کنید

عنوان ژورنال:

دوره   شماره 

صفحات  -

تاریخ انتشار 2014